import 'package:flutter/material.dart';
import 'package:jd_shopping/services/ScreenAdaper.dart';
import 'package:city_pickers/city_pickers.dart';

class Address extends StatefulWidget {
  @override
  _AddressState createState() => _AddressState();
}

class _AddressState extends State<Address> {
  String _address = '';
  @override
  Widget build(BuildContext context) {
    ScreenAdaper.init(context);
    return Scaffold(
      appBar: AppBar(title: Text('地址')),
      body: ListView(
        children: [
          Container(
            height: ScreenAdaper.height(90),
            color: Colors.white,
            child: Row(
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                      child: Text(
                        '收货人',
                        style: TextStyle(fontSize: 20, color: Colors.black),
                      ),
                    )),
                SizedBox(
                  width: ScreenAdaper.width(10),
                ),
                Expanded(
                    flex: 3,
                    child: TextField(
                      obscureText: false,
                      decoration: InputDecoration(
                          contentPadding:
                              const EdgeInsets.symmetric(vertical: 10.0),
                          hintText: '请输入收货人姓名',
                          hintStyle:
                              TextStyle(fontSize: 20, color: Colors.grey),
                          border:
                              OutlineInputBorder(borderSide: BorderSide.none)),
                      onChanged: (value) {
                        print(value);
                      },
                    ))
              ],
            ),
          ),
          Divider(
            height: 1,
          ),
          Container(
            height: ScreenAdaper.height(90),
            color: Colors.white,
            child: Row(
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                      child: Text(
                        '联系电话',
                        style: TextStyle(fontSize: 20, color: Colors.black),
                      ),
                    )),
                SizedBox(
                  width: ScreenAdaper.width(10),
                ),
                Expanded(
                    flex: 3,
                    child: TextField(
                      obscureText: false,
                      decoration: InputDecoration(
                          contentPadding:
                              const EdgeInsets.symmetric(vertical: 10.0),
                          hintText: '请输入电话号码',
                          hintStyle:
                              TextStyle(fontSize: 20, color: Colors.grey),
                          border:
                              OutlineInputBorder(borderSide: BorderSide.none)),
                      onChanged: (value) {
                        print(value);
                      },
                    ))
              ],
            ),
          ),
          Divider(
            height: 1,
          ),
          Container(
            height: ScreenAdaper.height(90),
            color: Colors.white,
            child: Row(
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                      child: Text(
                        '所在地址',
                        style: TextStyle(fontSize: 20, color: Colors.black),
                      ),
                    )),
                SizedBox(
                  width: ScreenAdaper.width(10),
                ),
                Expanded(
                  flex: 3,
                  child: InkWell(
                    child: Container(
                        child: Stack(
                      children: <Widget>[
                        Align(
                          alignment: Alignment.centerLeft,
                          child: Text(
                            '${this._address}',
                            style: TextStyle(color: Colors.black, fontSize: 20),
                          ),
                        ),
                        Align(
                          alignment: Alignment.centerRight,
                          child: Icon(Icons.arrow_forward_ios),
                        )
                      ],
                    )),
                    onTap: () async{
                    
                        Result result = await CityPickers.showCityPicker(
                        context: context,
                        theme: ThemeData.light()
                      );
                      setState(() {
                         this._address = result.provinceName +' '+ result.cityName +' ' + result.areaName;
                          print(result);
                        
                      });
                     
                    },
                  ),
                )
              ],
            ),
          ),
          Divider(
            height: 1,
          ),
          Container(
            height: ScreenAdaper.height(90),
            color: Colors.white,
            child: Row(
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                      child: Text(
                        '详细地址',
                        style: TextStyle(fontSize: 20, color: Colors.black),
                      ),
                    )),
                SizedBox(
                  width: ScreenAdaper.width(10),
                ),
                Expanded(
                    flex: 3,
                    child: TextField(
                      obscureText: false,
                      decoration: InputDecoration(
                          contentPadding:
                              const EdgeInsets.symmetric(vertical: 10.0),
                          hintText: '请输入详细地址',
                          hintStyle:
                              TextStyle(fontSize: 20, color: Colors.grey),
                          border:
                              OutlineInputBorder(borderSide: BorderSide.none)),
                      onChanged: (value) {
                        print(value);
                      },
                    ))
              ],
            ),
          ),
          Divider(
            height: 1,
          ),
          Container(
            height: ScreenAdaper.height(90),
            color: Colors.white,
            child: Row(
              children: [
                Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.fromLTRB(20, 0, 0, 0),
                      child: Text(
                        '邮政编码',
                        style: TextStyle(fontSize: 20, color: Colors.black),
                      ),
                    )),
                SizedBox(
                  width: ScreenAdaper.width(10),
                ),
                Expanded(
                    flex: 3,
                    child: TextField(
                      obscureText: false,
                      decoration: InputDecoration(
                          contentPadding:
                              const EdgeInsets.symmetric(vertical: 10.0),
                          hintText: '请输入邮政编码',
                          hintStyle:
                              TextStyle(fontSize: 20, color: Colors.grey),
                          border:
                              OutlineInputBorder(borderSide: BorderSide.none)),
                      onChanged: (value) {
                        print(value);
                      },
                    ))
              ],
            ),
          )
        ],
      ),
    );
  }
}
